﻿@model SlamDunk.CMS.Model.ViewModel.UserViewForManage

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>哈尔滨工业大学管理学院招生信息网 后台首页</title>
    <link href="~/EasyUI/themes/default/easyui.css" rel="stylesheet" />
    <link href="~/EasyUI/themes/icon.css" rel="stylesheet" />
    <script type="text/javascript" src="~/Scripts/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="~/EasyUI/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="~/EasyUI/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="~/EasyUI/jquery.easyui.GlobalParas.js"></script>
    <script type="text/javascript" src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script type="text/javascript" src="~/Scripts/jquery.validate.min.js"></script>
    <script type="text/javascript" src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
    <script type="text/javascript" src="~/Scripts/messageBox.js"></script>
    <script type="text/javascript" src="~/Scripts/datetools.js"></script>
    <script type="text/javascript">
        var messageBox = null;      //消息框
        var topHelper = {};             //提供给 iframe里子页面 操作当前页面 的一些便捷 方法
        $(function () {
            //初始化用户菜单
            $('#menuTree').tree({
                url: '/Admin/Menu/GetMenuList',
                animate: true,
                lines: true,
                onClick: function (e) {
                    addTab(e.text, e.attributes.href, e.attributes.isLink);
                }
            });
            //初始化消息框
            messageBox = new MessageBox({ imghref: '/Content/images/' });
            //注销用户按钮
            $('#btn_exit').linkbutton({
                iconCls: 'icon-cancel',
                plain: true,
                text: '注销用户'
            });
            //注销按钮事件
            $('#btn_exit').click(function () {
                $.messager.confirm('警告', '确定注销当前用户吗？', function (result) {
                    if (result) {
                        $.post('/Admin/User/Logout', null, function (jsonData) {
                            if (jsonData.Status == '1') {
                                window.location.href = jsonData.ReturnUrl;
                            }
                        }, 'json');
                    }
                })
            });
            //修改密码按钮
            $('#btn_padlock').linkbutton({
                iconCls: 'icon-lock',
                plain: true,
                text: '修改密码'
            });
            //修改密码按钮事件
            $('#btn_padlock').click(function () {
                //修改密码窗口
                $('#dvUpdatePwd').window('open');
                $('#dvUpdatePwd').window('setTitle', '修改密码');
                $('#fmUpdatePwd').form('clear');
            });
            //创建弹修改密码弹出窗口
            $('#dvUpdatePwd').window({
                width: 350,
                height: 200,
                maximizable: false,
                resizable: false,
                draggable: false,
                modal: true,
                minimizable: false,
                collapsible: false,
                closed: true
            });
            //初始化公共窗体
            topHelper.comWin = $('#commonWindow').window({
                width: 800,
                height: 500,
                collapsible: false,
                minimizable: false,
                maximizable: true
            }).window('close');
            //添加一个打开公共窗体的方法
            topHelper.showComWindow = function (title, url, width, height) {
                var trueTitle = "公共窗体";
                var trueWidth = 1200;
                var trueHeight = 500;
                if (title) trueTitle = title;
                if (width && parseInt(width) > 10) {
                    trueWidth = width;
                }
                if (height && parseInt(height) > 10) {
                    trueHeight = height;
                }
                //判断是否置顶url，如果有，则设置公共窗体里的iframe的src
                if (url && url.length && url.length > 10) {
                    $("#commonWindow iframe").attr("src", url);
                }
                //重新设置窗体的大小，并自动居中，然后才显示
                topHelper.comWin.window({
                    title: trueTitle,
                    width: trueWidth,
                    height: trueHeight
                }).window("center").window("open");
            };
            //添加一个关闭公共窗体方法
            topHelper.closeComWindow = function () {
                topHelper.comWin.window("close");
            }
        });

        //修改密码
        function changePwd() {
            var va = $("#oldPwd").val();
            var val = $("#newPwd").val();
            var val1 = $("#newPwd2").val();
            if (va.length == 0 || val.length == 0 || val1.length == 0) {
                messageBox.showMsgErr('密码不可为空，请重新输入！');
            } else if (val != val1) {
                messageBox.showMsgErr('两次密码不一致，请重试！');
            } else {
                //动态将用户Id赋值给隐藏域，否则接收不到
                $('#txtUserId').val(@Model.Id);                 //最恶心的就是这块
                $('#fmUpdatePwd').submit();
            }
        }
        //修改密码时执行
        function updatingPwd() {
            messageBox.showMsgWait("修改中，请稍后...");
        }
        //修改密码后执行
        function updatedPwd(jsonData) {
            if (jsonData.Status == 1) {
                $.messager.alert('OK', jsonData.Message);
                $('#dvUpdatePwd').window('close');
                window.location.href = jsonData.ReturnUrl;
            } else {
                messageBox.showMsgErr(jsonData.Message);
                $('#dvUpdatePwd').window('close');
            }
        }
        //添加tab方法
        function addTab(title, url, isLink) {
            //判断是否是链接
            if (isLink == '1') {          //是链接
                if ($('#tabs').tabs('exists', title)) {
                    var currTab = $('#tabs').tabs('getSelected');
                    $('#tabs').tabs('select', title);
                    var url = $(currTab.panel('options').content).attr('src');
                    if (url != undefined) {
                        $('#tabs').tabs('update', {
                            tab: currTab,
                            options: {
                                content: createFrame(url)
                            }
                        });
                    }
                } else {
                    var content = createFrame(url);
                    $('#tabs').tabs('add', {
                        title: title,
                        content: content,
                        closable: true
                    });
                }
            }
        }
        //创建iframe方法
        function createFrame(url) {
            var tabHeight = $("#tabs").height() - 35;
            var s = '<iframe scrolling="auto" frameborder="0"  src="' + url + '" style="width:100%;height:' + tabHeight + 'px;"></iframe>';
            return s;
        }
        //新增或修改成功后，可通过此方法更新tab里的DataGrid组件
        function updateDataGridInTab() {
            //1.获取后台首页的tab容器
            var $tabBox = $("#tabs");
            //2.获取选中的tab
            var $curTab = $tabBox.tabs('getSelected');
            //3.从选中的tab中获取iframe，并以jq对象返回
            var $ifram = $("iframe", $curTab);
            //4.从jq对象中获取iframe，并通过伟大的contentWindow对象操作iframe里的window的全局变量$tbGrid
            $ifram[0].contentWindow.$tbGrid.datagrid("clearSelections");         //清除选中
            $ifram[0].contentWindow.$tbGrid.datagrid("reload");                      //刷新表格
        }
    </script>
    <style type="text/css">
        body {
            font: 14px "微软雅黑";
        }

        #dvHeader {
            height: 70px;
            padding: 0px;
            background: url('/Content/images/banner-pic.gif') repeat;
            background-size: 100% 100%;
            overflow: hidden;
        }

            #dvHeader .logo {
                width: 372px;
                height: 68px;
                float: left;
                margin-left: 15px;
                background: url('/Content/images/Mlogo.jpg');
            }

            #dvHeader .rightBtns {
                float: right;
                margin-top: 4px;
                margin-right: 50px;
                height: 26px;
                text-align: right;
            }

            #dvHeader .welcomeLb {
                width: 300px;
                height: 20px;
                margin-top: 10px;
                font-size: 13px;
                text-align: left;
            }

        #dvContent {
            padding: 2px;
            background: #eee;
        }

            #dvContent .tabHome {
                padding: 0;
                background: url('/Content/images/welcom.jpg') no-repeat;
                background-size: 100% 100%;
            }

        #dvMenu {
            width: 230px;
        }

        #dvFooter {
            height: 20px;
        }

            #dvFooter .currentUser {
                float: left;
                margin-left: 20px;
            }

            #dvFooter .service {
                float: right;
                margin-right: 40px;
            }

                #dvFooter .service a {
                    color: #1336dd;
                }

        #dvUpdatePwd table input {
            width: 240px;
        }
    </style>
</head>
<body class="easyui-layout">
    <!-------------------------------------------网站头部--------------------------------------------->
    <div data-options="region:'north',split:false,border:false" id="dvHeader">
        <!--左边logo-->
        <div class="logo"></div>
        <!--左边logo-->
        <!--右边内容-->
        <div class="rightBtns">
            <!--注销用户、修改密码按钮-->
            <a class="easyui-linkbutton" id="btn_exit"></a>
            <a class="easyui-linkbutton" id="btn_padlock"></a>
            <!--注销用户、修改密码按钮-->
            <div class="welcomeLb">
                <span>欢迎您：@Model.RealName</span>
            </div>
        </div>
        <!--右边内容-->
    </div>
    <!-------------------------------------------网站头部--------------------------------------------->
    <!-------------------------------------网站中部，内容部分---------------------------------------->
    <div data-options="region:'center'" id="dvContent">
        <div class="easyui-tabs" id="tabs" data-options="headerWidth:200,fit:true">
            <div data-options="title:'首页'" class="tabHome">
                @*<iframe src="http://cn.bing.com" style="width: 100%; height: 99%; border: 0;"></iframe>*@
            </div>
        </div>
    </div>
    <!-------------------------------------网站中部，内容部分---------------------------------------->
    <!-------------------------------------网站左部，菜单部分---------------------------------------->
    <div data-options="region:'west',split:false" title="功能选项" id="dvMenu">
        <ul id="menuTree"></ul>
    </div>
    <!-------------------------------------网站左部，菜单部分---------------------------------------->
    <!-------------------------------------------网站底部--------------------------------------------->
    <div data-options="region:'south',border:false" id="dvFooter">
        <div class="currentUser">当前登录用户：@Model.UserName</div>
        <div class="service">
            <span>开发及技术支持——</span><a href="http://www.yhtd0451.com" target="_blank">银河天鼎科技开发有限公司</a>&nbsp;&nbsp;<span id="nowDate"></span>
        </div>
    </div>
    <!-------------------------------------------网站底部--------------------------------------------->
    <!---------------------------------------修改密码对话框---------------------------------------------->
    <div id="dvUpdatePwd">
        @using (Ajax.BeginForm("UpdatePassword", new { controller = "User" }, new AjaxOptions { OnSuccess = "updatedPwd" }, new { id = "fmUpdatePwd" }))
        {
            <input type="hidden" id="txtUserId" name="userId" value="" />
            <table style="width: 100%; text-align: right">
                <tr>
                    <td>旧密码:</td>
                    <td>@Html.Password("oldPwd")</td>
                </tr>
                <tr>
                    <td>新密码:</td>
                    <td>@Html.Password("newPwd")</td>
                </tr>
                <tr>
                    <td>确认密码:</td>
                    <td>@Html.Password("newPwd2")</td>
                </tr>
            </table>
            <div style="text-align: center; padding: 15px;">
                <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="changePwd();">保存</a>
                <a class="easyui-linkbutton" data-options="iconCls:'icon-reset'" onclick="javascript: $('#fmUpdatePwd').form('reset');">重置</a>
                <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript: $('#dvUpdatePwd').window('close')">取消</a>
            </div>
        }
    </div>
    <!---------------------------------------修改密码对话框---------------------------------------------->
    <!------------------------------------------公共窗口----------------------------------------------->
    <div id="commonWindow">
        <iframe id="comFrame" style="width: 100%; height: 99%; border: 0px;"></iframe>
    </div>
    <!------------------------------------------公共窗口----------------------------------------------->
</body>
</html>
